package y24.m3;

public class Test9 {
    static class Solution {
        public static int maxArea(int[] height) {
            int area = 0;
            int right = 0;
            int left = height.length - 1;
            while (right < left){
                if (height[right] > height[left]){
                    area = Math.max(area,height[left]*(left - right));
                    left--;
                }else {
                    area = Math.max(area,height[right] * (left - right));
                    right++;
                }
            }
            return area;
        }
    }

    public static void main(String[] args) {
        int[] arr = {1,8,6,2,5,4,8,3,7};
        System.out.println(Solution.maxArea(arr));

    }
}
